<template>
	<!-- 申请商家入驻 -->
	<view class="settled_wp">
		<view class="s_money">
			<text>￥</text><text>{{info.money}}</text>
		</view>
		<view class="s_message">{{info.remarket}}</view>
		<view class="s_lock" @click="$navTo('../notice/moduleCont?id=904')">查看【申请教程和权益】</view>
		<view class="s_agreement">
			<checkbox-group style="display: inline-block;" @change="change">
				<checkbox style="transform:scale(0.8)" value="true" />我已阅读并同意
			</checkbox-group>
			<text @click="$navTo('https://h5.bkyh.top/settled.html')">《多米街平台商家入驻协议》</text>
		</view>
		<view class="pay_buttons">
			<view v-for="item in info.payment" :key="item.type" @click="onsumbit(item.type)">
				<image v-if="item.type==1" src="/static/user/weixin.png"></image>
				<text v-if="item.type==1">微信支付</text>

				<image v-if="item.type==2" src="/static/user/zhifubao.png"></image>
				<text v-if="item.type==2">支付宝支付</text>
			</view>
		</view>
	</view>
</template>

<script>
	var apptype = '1';
	// #ifdef MP-WEIXIN
	apptype = "3";
	// #endif
	export default {
		data() {
			return {
				checked: false,

				info: {
					money: 0,
					payment: []
				},

			}
		},
		onLoad() {
			this.getinfo();
		},
		methods: {
			getinfo() {
				this.$axios('Paysh/display', 'POST', 'order', {
					apptype
				}).then(res => {
					if (res.data.code == 200) {
						this.info = res.data.data;
					}
				})
			},
			change(e) {
				this.checked = Boolean(e.detail.value[0]);
			},
			onsumbit(type) {
				if (!this.checked) {
					this.$api.msg('请同意入驻协议')
					return;
				};
				uni.showLoading({
					title: '支付中'
				})
				this.$axios('Paysh/recharge', 'POST', 'order', {
					apptype,
					type
				}).then(res => {
					if (res.data.code == 200) {
						let data = res.data.data;
						uni.requestPayment({
							provider: 'wxpay',
							timeStamp: data.timeStamp,
							nonceStr: data.nonceStr,
							package: data.package,
							signType: 'MD5',
							paySign: data.sign,
							success: function(res) {
								that.$navTo('../individualism/user')
							},
							fail: function(err) {
								that.$axios('orderconf/main', 'POST', 'order').then(res => {});
								that.$api.msg('支付失败');
							}
						});
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	.settled_wp {
		padding-bottom: 130upx;
		color: $font-color-dark;
		text-align: center;
	}

	.s_money {
		color: $base-color;
		font-size: 36upx;
		padding-top: 110upx;
	}

	.s_money text:nth-of-type(1) {
		font-size: $font-base;
	}

	.s_message {
		color: $font-color-light;
	}

	.s_lock {
		color: $base-color;
		padding: 30upx;
		font-size: 36upx;
	}

	.s_agreement {
		padding: 30upx 0 110upx;
	}

	.s_agreement text {
		color: $base-color;
	}

	.pay_buttons view {
		border: 1px hsl(0, 0%, 87%) solid;
		border-radius: 40upx;
		font-size: $font-base;
		line-height: 70upx;
		letter-spacing: 2px;
		margin: 0 auto 50upx;
		width: 60%;
	}

	.pay_buttons image {
		border-radius: 50%;
		height: 40upx;
		margin-right: 20upx;
		width: 40upx;
		vertical-align: middle;
	}
</style>
